﻿Public Class OdemePlaniRaporuIsyeri2009 : Inherits OdemePlaniRaporuIsyeri

	Sub New()
		MyBase.New()
		Yil = 2009
	End Sub

End Class

Public Class OdemePlaniRaporuIsyeri
	Inherits ProcessReport

	Public Yil As Integer
	Dim Rsg, Rst As Recordset

	Public Overrides Sub GenericEvent(ByVal e As ProcessEventArgs)
		Select Case e.EventType
			Case EventType.Initialize
				Start("İşyeri Prim Borcu Ödeme Planı", "İşyeri bilgisini girin.")
				AddIsyeri()
			Case EventType.Shown
				If Not Arguments.ContainsKey("isyerino") Then Exit Sub
				SetValues("Isyeri", Arguments("isyerino"))
				Report.Focus()
			Case EventType.ValidateForm
				Rsg = Hukuk.Af.GenelIsyeriOku(Local, Yil, Input("Isyeri"))
				If Check("Isyeri", Rsg.EOF, "Bu işyeri aftan yararlandırılmadı.") Then Exit Sub
				e.Result = True
			Case EventType.CoverPage
				Dim Rs As Recordset = Isyeri.IsyeriNoAra(Local, Input("Isyeri"))
				Report.PrintHeader(Yil & " AFFI PRİM BORÇLARI ÖDEME PLANI")
				Report.SetColumns("İşyeri No.;Sicil No.;İşyeri Adı;Tehlike S.;Peşin Öde. Tar.", "2;3;6;2;2", "c;c;l;c;d", "-")
				Report.Print(Rs("isyerino"), Rs("sicilno"), Rs("isyeriadi"), Rs("tehlike"), Rsg("pesintar"))
				Report.SkipLine()
				Report.SetColumns("", "3;2;2;2;2;2;2;2;2;2", "c;m;m;m;m;m;m;m;m;m", "--")
				Report.Print("<rs=2><c><g=1>Dönem", "<cs=3><c><g=1>Toplam Borç", "<cs=3><c><g=1>Peşin Ödenecek", "<cs=3><c><g=1>Taksitlendirilecek")
				Report.Print("<c><g=1>Anapara", "<c><g=1>Ceza (%30)", "<c><g=1>Toplam", "<c><g=1>Anapara", "<c><g=1>Ceza (%30)", "<c><g=1>Toplam", "<c><g=1>Anapara", "<c><g=1>Ceza (%30)", "<c><g=1>Toplam")
				Rst = Hukuk.Af.TaksitIsyeriOku(Local, Yil, Input("Isyeri"))
				For j As Integer = 0 To 2
					Dim Donem As String = Choose(j + 1, "<g=1>2000 Öncesi", "<g=1>2000 Sonrası", "<g=1>Toplam")
					Dim f As String = Choose(j + 1, "donem < '2000'", "donem >= '2000'", "1 = 1")
					Report.Print(Donem,
					 Rst.Sum("anapara", f), Rst.Sum("ceza", f), Rst.Sum("toplam", f),
					 Rst.Sum("anapara", f & " and tur = 'P'"), Rst.Sum("ceza", f & " and tur = 'P'"), Rst.Sum("toplam", f & " and tur = 'P'"),
					 Rst.Sum("anapara", f & " and tur = 'T'"), Rst.Sum("ceza", f & " and tur = 'T'"), Rst.Sum("toplam", f & " and tur = 'T'"))
				Next
				Report.SkipLine()
			Case EventType.PageHeader
				Report.SetColumns("Bordro Tar.;Bordro;Anapara;Ceza;İnd.Ceza;Toplam;P/T;Öde.Tar.", "2;1;2;2;2;2;1;2", "d;c;m;m;m;m;c;d", "--")
			Case EventType.ReportDetail
				Rs = Rst
				For Each Row In Rst
					Report.Print(Rs("bordrotar"), Rs("bordro"), Rs("anapara"), Rs("ceza") / 0.3, Rs("ceza"), Rs("anapara") + Rs("ceza"), Rs("tur"), If(Rs("tur") = "P", DBNull.Value, Rs("odetar")))
				Next
				If Not Rs.Count = 0 Then Report.PrintTotal("", "", Rs.Sum("anapara"), Rs.Sum("ceza") / 0.3, Rs.Sum("ceza"), Rs.Sum("anapara") + Rs.Sum("ceza"), "", DBNull.Value)
		End Select
	End Sub

End Class
